package com.txl.cn.lc

import com.alibaba.fastjson.JSON
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by txl on 2018/6/27.
  */
object OrderDemo {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
      .setAppName(this.getClass.getName)
      .setMaster("local[*]")
    val sc = new SparkContext(conf)
    val data = sc.textFile("data/json/test.json")
    val res: RDD[(String, Int, Int)] = data.map(JSON.parseObject(_)).map(t => {
      val province = t.getString("province")
      val sums = t.getString("sums").toInt
      val rank = t.getString("rank").toInt
      (province, sums, rank)
    })
    res.sortBy(t => (t._2),false).collect().foreach(println)

  }

}
